import { getGameObjectById } from "../engine";
import { Behaviour } from "../engine/Behaviour";
import { Audio } from "../engine/Audio";
import { BitmapRenderer } from "../engine/BitmapRenderer";

export class ControlMenu extends Behaviour {

    IsBgmOpen:boolean=true;
    IsQuit:boolean=false;
    onStart(){
        getGameObjectById('backgoundSound').getBehaviour(Audio).Play();
        getGameObjectById('backgoundSound').getBehaviour(Audio).ChangeVolume(0.1);    
        this.gameObject.onClick = () => {
                console.log("背景音乐：",this.IsBgmOpen)
                if(this.IsBgmOpen){
                    getGameObjectById("UI_button_settings").getBehaviour(BitmapRenderer).source="./assets/images/UI_button_mute.png"
                    getGameObjectById('backgoundSound').getBehaviour(Audio).ChangeVolume(0.1);    
                    getGameObjectById('backgoundSound').getBehaviour(Audio).Pause();
                    this.IsBgmOpen=false;
                }else{
                    getGameObjectById("UI_button_settings").getBehaviour(BitmapRenderer).source="./assets/images/UI_button_volume.png"
                    getGameObjectById('backgoundSound').getBehaviour(Audio).ChangeVolume(0.1); 
                    getGameObjectById('backgoundSound').getBehaviour(Audio).Play(); 
                    this.IsBgmOpen=true;
                }
        }
       getGameObjectById("UI_button_quit").onClick = () => {
        console.log("UI_button_quit")
        this.IsQuit=true
       }
       getGameObjectById("UI_button_restart").onClick = () => {
        console.log("UI_button_restart")
        //this.engine.scenenumber=1
       }
    }
    
}